<template xmlns:el-col="http://www.w3.org/1999/html">
    <div style=" user-select: none;">
        <div class="crumbs">
            <el-breadcrumb separator="/">
                <el-breadcrumb-item>
                    <i class="el-icon-lx-cascades"></i> 患者信息
                </el-breadcrumb-item>
            </el-breadcrumb>
        </div>
        <div class="container">
            <div class="handle-box">
                <el-input v-model="query.ptNm" placeholder="姓名" class="handle-input mr10"
                          @keyup.enter.native="handleSearch" style="width: 16%"></el-input>
                <el-select v-model="query.ptSex" placeholder="性别" class="handle-select mr10"
                           @keyup.enter.native="handleSearch" style="width: 16%">
                    <el-option key="00" label="男" value="00"></el-option>
                    <el-option key="01" label="女" value="01"></el-option>
                </el-select>
                <el-button type="primary" icon="el-icon-search" @click.native="handleSearch">搜索</el-button>
                <el-button type="el-button" icon="el-icon-delete" @click.native="handleReset">重置</el-button>
            </div>
            <el-table
                    :data="tableData"
                    border
                    class="table"
                    ref="multipleTable"
                    header-cell-class-name="table-header"
                    @selection-change="handleSelectionChange"
            >
                <el-table-column prop="ptId" label="患者编号" align="center"></el-table-column>
                <el-table-column prop="ptNm" label="姓名" align="center"></el-table-column>
                <el-table-column prop="ptSexText" label="性别" align="center"></el-table-column>
                <el-table-column prop="ptAge" label="年龄" align="center"></el-table-column>
                <el-table-column prop="createdTime" label="创建时间" align="center"></el-table-column>
            </el-table>
            <div class="pagination">
                <el-pagination
                        background
                        layout="total, prev, pager, next"
                        :current-page="query.pageIndex"
                        :page-size="query.pageSize"
                        :total="pageTotal"
                        @current-change="handlePageChange"
                ></el-pagination>
            </div>
        </div>


    </div>
</template>

<script>
    import {patientData,} from '../../../api/ds/patient';
    export default {
        name: 'patient',
        data() {
            return {
                query: {//检索条件
                    ptNm: '',
                    ptSex: '',
                    /*userAcct:localStorage.getItem('ms_userAcct'),*/
                    pageIndex: 1,
                    pageSize: 10
                },
                tableData: [],
                multipleSelection: [],
                editVisible: false,
                prescriptionVisible: false,
                pageTotal: 0,
                idx: -1,
                id: -1,
                total: 1,
            };
        },

        created() {
            this.getData();
        },
        methods: {
            // 获取 easy-mock 的模拟数据
            getData() {
                patientData(this.query).then(res => {
                    this.tableData = res.data;
                    this.pageTotal = res.total;
                });
            },
            // 触发搜索按钮
            handleSearch() {
                this.$set(this.query, 'pageIndex', 1);
                this.getData();
            },
            // 触发重置按钮
            handleReset() {
                this.query.ptNm = "";
                this.query.ptSex = "";
                this.getData();
            },
            // 多选操作
            handleSelectionChange(val) {
                this.multipleSelection = val;
            },
            // 分页导航
            handlePageChange(val) {
                this.$set(this.query, 'pageIndex', val);
                this.getData();
            },
        }
    };
</script>
<style scoped>
    .handle-box {
        margin-bottom: 20px;
    }

    .handle-select {
        width: 120px;
    }

    .handle-input {
        width: 300px;
        display: inline-block;
    }

    .table {
        width: 100%;
        font-size: 14px;
    }

    .red {
        color: #ff0000;
    }

    .mr10 {
        margin-right: 10px;
    }

    .schart {
        width: 550px;
        height: 300px;
    }

    .content-title {
        clear: both;
        font-weight: 400;
        line-height: 50px;
        margin: 10px 0;
        font-size: 22px;
        color: #1f2f3d;
    }
</style>
